<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<base href="/webcon/resources/"/>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
		<link rel="stylesheet" href="layui/css/layui.css">
		<link rel="stylesheet" href="css/timing.css">

		<script src="js/jquery-3.5.0.min.js"></script>
		<script src="layui/layui.js"></script>


		<!-- 引入ztree -->
		<link rel="stylesheet" href="widget/zTree/zTreeStyle/zTreeStyle.css"/>
		<script type="text/javascript" src="widget/zTree/jquery.ztree.all.min.js"></script>

		<!-- 自定义js -->
		<script type="text/javascript" th:src="${#request.getContextPath() + '/commons/js/myztree.js'}"></script>
		<script type="text/javascript" th:src="${#request.getContextPath() + '/commons/js/myajax.js'}"></script>
		<script type="text/javascript" th:src="${#request.getContextPath() + '/commons/js/mytask.js'}"></script>
		<script type="text/javascript" th:src="${#request.getContextPath() + '/commons/js/task_voice.js'}"></script>
		<script type="text/javascript" th:src="${#request.getContextPath() + '/commons/js/mytask_status.js'}"></script>


		<script th:inline="javascript">
			$(function () {
				//初始化任务列表
				initVoiceTask();
			});

			var openFile = function(event) {
				var input = event.target;
				var reader = new FileReader();
				reader.onload = function() {
					if(reader.result) {
						//显示文件内容
						$("#info").val(reader.result);
					}
				};
				reader.readAsText(input.files[0], 'gbk');

			};
		</script>

		<!-- 日期插件 -->
		<link rel="stylesheet"
			  th:href="${#request.getContextPath() + '/system/resources/widget/My97DatePicker/skin/WdatePicker.css'}"
			  type="text/css"/>
		<script type="text/javascript"
				th:src="${#request.getContextPath() + '/system/resources/widget/My97DatePicker/WdatePicker.js'}"></script>




	</head>
	<body>
		<div class="header">
			<div class="list-item" onclick="openModal(0)">
				<div class="list-item-top">
					<img src="./img/xinjian.png" />
				</div>
				<div class="desc">新建任务</div>
			</div>
			<div class="list-item" onclick="openModal(1)">
				<div class="list-item-top">
					<img src="./img/bianji.png" />
				</div>
				<div class="desc">编辑任务</div>
			</div>
			<div class="list-item" onclick="isAction(2, 4);">
				<div class="list-item-top">
					<img src="./img/shanchu.png" />
				</div>
				<div class="desc">删除任务</div>
			</div>
			<div class="list-item" onclick="action_task();">
				<div class="list-item-top">
					<img src="./img/bofang.png" />
				</div>
				<div class="desc">手动执行</div>
			</div>
			<div class="list-item" onclick="stop_task();">
				<div class="list-item-top">
					<img src="./img/tingzhi.png" />
				</div>
				<div class="desc">手动停止</div>
			</div>
		</div>

		<table class="layui-table">
			<thead>
			<tr>
				<th>任务名称</th>
				<th>任务状态</th>
				<th>开始时间</th>
				<th>停止时间</th>
				<th>循环次数</th>
				<th>播音员</th>
			</tr>
			</thead>
			<tbody id="task_list">
			<!-- TODO 任务列表 -->
			</tbody>
		</table>

		<div id="tt" style="padding:20px 35px;display: none;">
			<div class="item" style="width: 260px;">
				<div style="padding: 10px 10px;">

					<div class="layui-row">
						<div class="layui-col-md4">
							<span class="task-name">语音内容:</span>
						</div>
						<div class="layui-col-md8">
							<textarea id="info" class="layui-textarea" placeholder="请输入文本信息"
									  style="width: 100%; height: 83px;"></textarea>
						</div>
					</div>
					<div class="layui-row">
						<div class="layui-col-md4">
							<span class="task-name">选择文件:</span>
						</div>
						<div class="layui-col-md8">
							<input type='file' accept='text/plain' onchange='openFile(event)'/><br>
						</div>
					</div>


					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">任务名称:</span>
						</div>
						<div class="layui-col-md8">
							<input type="text" id="taskname" placeholder="任务名称"
								   required lay-verify="required" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">任务类型:</span>
						</div>
						<div class="layui-col-md8 layui-form">
							<select id="playOrder" lay-filter="playOrder" lay-verify="">
								<option value="1">每天任务</option>
								<option value="2">每周任务</option>
								<option value="3">一次任务</option>
							</select>
						</div>
					</div>
					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">开始日期:</span>
						</div>
						<div class="layui-col-md8">
							<input id="startDate" type="text" placeholder="开始日期"
								   required lay-verify="required" autocomplete="off" class="layui-input"
								   onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
						</div>
					</div>
					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">开始时间:</span>
						</div>
						<div class="layui-col-md8">
							<input id="startTime" type="text" placeholder="开始时间"
								   required lay-verify="required" autocomplete="off" class="layui-input"
								   onclick="WdatePicker({dateFmt:'HH:mm'})">
						</div>
					</div>
					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">结束时间:</span>
						</div>
						<div class="layui-col-md4">
							<input id="endTime" type="text" placeholder="结束时间"
								   required lay-verify="required" autocomplete="off" class="layui-input"
								   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" disabled="disabled"/>
						</div>
						<div class="layui-col-md4 layui-form" style="text-align: right;">
							<input id="checkbox_end" type="checkbox" lay-filter="checkbox_end"
								   lay-skin="switch" lay-text="ON|OFF"/>
						</div>
					</div>
					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">播报员:</span>
						</div>
						<div class="layui-col-md8 layui-form">
						<select id="reporter" lay-verify="">
							<option value="0">普通女声（默认）</option>
							<option value="1">普通男声</option>
							<option value="2">特别男声</option>
							<option value="3">情感男声(度逍遥)</option>
							<option value="4">情感儿童声(度丫丫)</option>
						</select>
						</div>
					</div>
					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">语音速度:</span>
						</div>
						<div class="layui-col-md8">
							<input type="text" id="speed" placeholder="语速"
								   value="5" required lay-verify="required" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-row" style="padding-top: 5px;">
						<div class="layui-col-md4">
							<span class="task-name">循环次数:</span>
						</div>
						<div class="layui-col-md8">
							<input type="text" id="loopnum"
								   required lay-verify="required" autocomplete="off" class="layui-input" value="1">
						</div>
					</div>
					<div style="padding-top: 5px;">
						<div class="layui-row">
							<div class="layui-col-md12">
								<span class="task-name">星期选择:</span>
							</div>
						</div>
						<div class="layui-row" style="margin-bottom: 5px;">
							<div class="layui-col-md4  layui-form">
								<input name="week" type="checkbox" value="2"
									   disabled="disabled" title="星期一" lay-skin="primary"/>
							</div>
							<div class="layui-col-md4  layui-form">
								<input name="week" type="checkbox" value="4"
									   disabled="disabled" title="星期二" lay-skin="primary"/>
							</div>
							<div class="layui-col-md4  layui-form">
								<input name="week" type="checkbox" value="8"
									   disabled="disabled" title="星期三" lay-skin="primary"/>
							</div>
						</div>
						<div class="layui-row" style="margin-bottom: 5px;">
							<div class="layui-col-md4  layui-form">
								<input name="week" type="checkbox" value="16"
									   disabled="disabled" title="星期四" lay-skin="primary"/>
							</div>
							<div class="layui-col-md4  layui-form">
								<input name="week" type="checkbox" value="32"
									   disabled="disabled" title="星期五" lay-skin="primary"/>
							</div>
							<div class="layui-col-md4  layui-form">
								<input name="week" type="checkbox" value="64"
									   disabled="disabled" title="星期六" lay-skin="primary"/>
							</div>
						</div>
						<div class="layui-row">
							<div class="layui-col-md12  layui-form">
								<input name="week" type="checkbox" value="128"
									   disabled="disabled" title="星期天" lay-skin="primary"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="item item2">
				<div style="padding-left: 10px;padding-top: 10px;">
					<span>终端列表：</span>
					<input class="selectAll" onclick="selectAll()" style="width: 18px;height: 18px;position: relative;top: 4px;" type="checkbox">
					全选
				</div>
				<!-- 树形选择器 -->
				<div id="ztree_div" class="ztree"
					 style="height: 430px; overflow:scroll; overflow-y: auto; overflow-x: auto;"></div>
			</div>
		</div>
		

		<script>
			var checked = false
			$(".selectAll").attr("checked", checked)
			layui.use(['table', 'form', 'layer', 'tree', 'upload', 'laydate'], function() {
				var table = layui.table;
				var form = layui.form;
				var layer = layui.layer;
				var laydate = layui.laydate;
				//执行一个laydate实例
				laydate.render({
					elem: '#date1' //指定元素
				});

				//播放类型选择事件
				form.on('select(playOrder)', function (data) {
					//TODO执行自己的代码
					select_type(data.value, 2);
				});

				//监听开关事件
				form.on('switch(checkbox_end)', function (data) {
					var contexts;
					var x = data.elem.checked;//判断开关状态
					//修改状态
					open_end(x);
					return true;
				});
			});

			function openModal(num) {
				layer.open({
					type: 1,
					area: ['600px', '450px'],
					title: '语音合成',
					offset: '20px',
					btn: ['确定','取消'],
					shade: 0.6,
					maxmin: false,
					anim: 4,
					content: $("#tt"),
					yes: function(index, layero){
						if(num == 0){
							//提交任务
							submit_task();
						} else if(num == 1){
							//修改任务
							var task = $("[alt='del']")[0];
							var tid = task.getAttribute("taskidstr");
							update_task(tid);
						}

						return true;
					},success: function(layero, index){
						$('body').attr('style','overflow:hidden')

						if(num == 0){
							//创建语音合成任务
							open_Model(4);
						} else if(num == 1){
							//编辑任务
							isAction(1, 4);
						}
					},
					cancel: function(index, layero){
						$('body').removeAttr('style')
					}
				});
			}
		</script>
	</body>
</html>
